package com.chixing.day05.Fuxi;

import com.chixing.day04.Car;

//复习
public class ReviewOOP {
    private int age; //成员变量

    public void fun(int age) { //形参 param,临时变量,作用域范围就在该方法中
        /*eg: /day02/SortUtil;
              /day04/SortUtil; 类名相同,但表达的含义不同
         */
        int a = 10;
        int b = a; //在栈中,将a的值复制给b;


        //导包
        Car c1 = new Car();
        Car c2 = c1;     //指向同一堆内存


        //继承
        class Animal {
        }
        class Dog extends Animal {
        }


        Dog dog = new Dog();  //this dog is the dog;
        Animal an1 = new Dog(); //this dog is the animal
        Object o1 = new Dog();
        //ClassCastException:类型转换异常
        Animal an2 = new Animal();
        //Dog dog1 = new Dog(); // 编译报错

        Dog dog2 = (Dog) an2;  //error 强制类型转换 【an2 在堆内存中 是animal类型】
        Dog dog3 = (Dog) an1; //sure [an1 在堆内存中 是 dog类型]

        System.out.println(dog3 instanceof Dog); //true
        System.out.println(dog3 instanceof Animal); //false

        //为了比卖你强制类型转换异常,在强转之前，先进性判断
     /*   if(ca3 instanceof CreditAccount){
            ca3 = (CreditAccount) new Account();
        }*/
    }

}
